var MongoClient = require('mongodb').MongoClient,
    test = require('assert');
var async = require('async');

module.exports = function(callback){
    MongoClient.connect('mongodb://localhost:27017/project_name', function(err, db) {
        var report = {};
        var count = function(name,cb){
            var collection = db.collection(name);
            collection.count(function(err,count){
                report[name] = count;
                cb();
            });
        }
        db.listCollections().toArray(function(err, items) {
            //test.equal(1, items.length);
            for(var i in items){
                var item = items[i];
                var name = item.name.split('.')[1];
                console.log(name);
            }
            async.each(items,function(item,cb){
                var name = item.name.split('.')[1];
                count(name,cb);
            },function(err){
                callback(report);
            })
        });

    });
}
